define("pages/jls_cs/gjhdform", [
        '../../pages/jls_cs/gjhdform.html.js',
        "../../plugins/artTemplate/artTemplate"
    ],
    function(require){
        var comonts=require("../../common/componts");
        comonts.initSelectPage(undefined);
        comonts.initSelect(undefined,undefined,undefined);
        var _show=function(_jbxx,_jkjc,refresh){
            var tmp= require("../../pages/jls_cs/gjhdform.html");
            var comonts = require("../../common/componts");
            var htmlcompile = template.compile(tmp);
            var html = htmlcompile(
                {
                    jbxx:_jbxx,
                    data:_jkjc
                });
            $("#csdj").dialog('destroy')  //使用destroy来销毁dialog
            $("#csdjdialog").html(html);  //取出id为jkjcdialog元素的内容
            $.parser.parse($("#csdjdialog"));  //动态渲染
            //初始化下拉框
            comonts.initSelectPage(undefined);
            comonts.initSelect(undefined,undefined,undefined);
            var date = new Date();
            var str = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
            var str1 = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
            $("#tbrqfm").datebox("setValue",str1);
            $("#csdj").window('open');
            $('.input_td').find('span').css("border-top","none");
            $('.input_td').find('span').css("border-right","none");
            $('.input_td').find('span').css("border-left","none");
            $('.validatebox-invalid').css("background","#fff");
            console.log(_jbxx)

            bindAction(refresh);
        }






        var save = function(refresh){
            var url = " /kss_xyr/saveZbsy";
            var validate=$("#xzry").form('validate');
            if (validate) {
                var data =$("#fm").serialize();
                submitLoad();
                $.ajax({
                    type : "POST",  //提交方式
                    url : url,
                    data : data,//数据，这里使用的是Json格式进行传输
                    success : function(result) {
                        if (result.result=='success') {
                            $.messager.alert("确定","保存成功","info");
                            $('#xzry').window('close');
                            refresh();
                        }else{
                            removeLoad();
                            $.messager.alert("确定","保存失败","info");
                        }
                    },
                    complete:function(){
                        removeLoad();
                    },
                });
            }else{
                $.messager.alert("提示", '必填项不能为空！');
            }
        }

        var bindAction=function(refresh){
            $("#gjhd_save").on("click",function(){
                save(refresh);
            });
            $("#gjhd_cancel").on("click",function(){
                $("#csdj").dialog("close");
            });
        }

        return{
            show:_show
        }
    });
